package com.hqj.client.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hqj.client.entity.Menu;
import com.hqj.client.mapper.MenuMapper;
import com.hqj.client.service.MenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 黄啟军
 * @version 1.0
 * @date 2020/5/16/016
 */
@Service
public class MenuServiceImpl implements MenuService {

    @Resource
    private MenuMapper menuMapper;
    /**
     * Menu分页查询
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<Menu> findPage(int page, int size){
        //QueryWrapper<Menu> wrapper = new QueryWrapper<>();
        IPage<Menu> findpage = menuMapper.selectPage(new Page<>(page, size),null);
        return findpage.getRecords();
    }
    /**
     * 删除
     * @param id
     */
    @Override
    public int delete(Long id){
        Menu menu = menuMapper.selectById(id);
       // menu.setIsDelete(1);
        return menuMapper.updateById(menu);

    }
    /**
     * 修改Menu
     * @param menu
     */
    @Override
    public int update(Menu menu){
        return menuMapper.updateById(menu);
    }
    /**
     * 增加Menu
     * @param menu
     */
    @Override
    public int add(Menu menu){
        return menuMapper.insert(menu);
    }
    /**
     * 根据ID查询Menu
     * @param id
     * @return
     */
    @Override
    public Menu findById(Long id){

        return  menuMapper.selectById(id);
    }
    /**
     * 查询Menu全部数据
     * @return
     */
    @Override
    public List<Menu> findAll() {
        return menuMapper.selectList(null);
    }
}
